package com.swe727.spring2011.constraint1.client.util;
import com.swe727.spring2011.constraint1.observation.*;

import com.swe727.spring2011.constraint1.coordinate.*;
import com.swe727.spring2011.constraint1.observation.ObservationType;
import java.util.*;
public class ObservationSimulator {
	/*return observation type given probability from class
	 * 
	 * As directed by Prof. Sousa
	 * A collection of observations is returned based on the random selection of 
	 * 
	 * moveRandom x = new Random(System.currentTimeMillis());
	 * <...>
	 * booleanfire = (x.nextFloat() < 0.05);
	 * <...>float m = x.nextFloat();
	 * booleanstay = (m<0.20);
	 * booleanmove_east= (0.20<=m && m<0.30);
	 * 
	 * */
	ObservationType[] cards = new ObservationType[100];
	int retrieveCount = 0;
	
	public ObservationSimulator() {
		
	}
	
	
	public ArrayList<Observation> getObservation(Coordinate coord) {

		ArrayList<Observation> observations= new ArrayList<Observation>();

		 Random x = new Random(System.currentTimeMillis());
		 
		 boolean fire = x.nextFloat() < 0.02; //* fire=2%
		 boolean flood = x.nextFloat() < 0.30; //* flooded road=30%
		 boolean looting = x.nextFloat() < 0.05; //* looting=5%
		 boolean supplies = x.nextFloat() < 0.1; //* supplies available=10%
		 boolean medevac = x.nextFloat() < 0.05; //* medevac=5%
		 
		 if (fire)
			 observations.add(new Observation(ObservationType.FIRE,coord));

		 if (flood)
			 observations.add(new Observation(ObservationType.FLOODED_ROAD, coord));
			 
		if (looting)
			observations.add(new Observation(ObservationType.LOOTING, coord));
		
		if (supplies)
			observations.add(new Observation(ObservationType.SUPPLIES_AVAILABLE, coord));
		
		if (medevac)
			observations.add(new Observation(ObservationType.MEDEVAC, coord));
				
		 return observations;
	}

}
